void solve()
{
  int n;
  cin >> n;

  string s;
  cin >> s;
  s = " " + s;

  vl dp(n + 1);
  ll ans = 0;
  rep(i, 1, n) {
    if (s[i] == '0') {
      dp[i] = dp[i - 1];
    } else {
      dp[i] = dp[max(i - 3, 0)] + i;
    }
    ans += dp[i];
  }

  cout << ans << '\n';
}